$OpenBSD: patch-src_pitchschmitt_c,v 1.1.1.1 2012/08/16 15:08:09 stsp Exp $
Fix an out-of-bounds array access during 'make regress'.
--- src/pitchschmitt.c.orig	Thu Jul 27 01:27:23 2006
+++ src/pitchschmitt.c	Thu Aug 16 12:50:53 2012
@@ -73,9 +73,9 @@ smpl_t aubio_schmittS16LE (aubio_pitchschmitt_t *p, ui
       t1 =   (sint_t)( A1 * trigfact + 0.5);
       t2 = - (sint_t)( A2 * trigfact + 0.5);
       startpoint=0;
-      for (j=1; schmittBuffer[j]<=t1 && j<blockSize; j++);
-      for (; !(schmittBuffer[j]  >=t2 &&
-	       schmittBuffer[j+1]< t2) && j<blockSize; j++);
+      for (j=1; j<blockSize && schmittBuffer[j]<=t1; j++);
+      for (; j<blockSize-1 && !(schmittBuffer[j]  >=t2 &&
+	       schmittBuffer[j+1]< t2); j++);
       startpoint=j;
       schmittTriggered=0;
       endpoint=startpoint+1;
